import {Injectable} from "@angular/core";
import "rxjs/add/operator/map";
import "rxjs/add/operator/catch";
import {Http} from "@angular/http";
import {UrlData} from "../../common/urldata";
import {UserData} from "../../common/user.data";
import {ExceptionHandler} from "../../common/exception.handler";
/**
 * 收藏
 */
@Injectable()
export class ArticleFavoriteService {

  constructor(private http: Http,
              private urlData: UrlData,
              private user: UserData,
              private exceptionHandler: ExceptionHandler) {
  }

  query(data: any) {
    data.token = this.user.token;
    return this.http
      .get(this.urlData.baseUrl + `v1/article/favorite`, {params: data})
      .map(response => response.json())
      .catch(err => this.exceptionHandler.handleError(err));
  }
}
